package com.missfresh.cooperation2meituan.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.missfresh.cooperation2meituan.dao.OrderDao;
import com.missfresh.cooperation2meituan.service.OrderService;
import com.missfresh.cooperation2meituan.util.SignUtil;

@Service("OrderService")
public class OrderServiceImpl implements OrderService {
	
	@Value("${app.id}")
	private String app_id;
	
	@Value("${order.receive.url}")
	private String receiveUrl;
	
	@Autowired
	private OrderDao orderDao;

	@Override
	public boolean checkSig(List<String> list,String sig) {
		String sign = SignUtil.createSign(list, receiveUrl);
		if(sign.equals(sig)){
			return true;
		}else{
			return false;
		}
	}
	
	@Override
	public boolean addOrder(Map<String, Object> map) {
		return orderDao.addOrder(map) > 0;
	}

	@Override
	public List<Map<String, Object>> queryMeituanOrders(Map<String, Object> map) {
		return orderDao.queryMeituanOrders(map);
	}

	@Override
	public long queryMeituanOrdersCount(Map<String, Object> map) {
		return orderDao.queryMeituanOrdersCount(map);
	}

	@Override
	public Map<String,Object> queryStoreCode(String app_poi_code) {
		return orderDao.queryStoreCode(app_poi_code);
	}

}
